package com.lidong.lowcode.model.controller;

import com.lidong.config.controller.BaseController;
import com.lidong.config.domain.gloabreturn.ResponseInfo;
import com.lidong.lowcode.base.domain.TreeVO;
import com.lidong.lowcode.model.service.BaseGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 7/21/2022 9:00 PM
 */
@RestController
@RequestMapping("/lowcode/basegroup")
public class BaseGroupController extends BaseController {

    @Autowired
    private BaseGroupService baseGroupService;

    /**
     * 根据类型获取分组树
     *
     * @return ResponseInfo
     */
    @RequestMapping("/tree/{groupType}")
    public ResponseInfo<List<TreeVO>> getBaseGroupTreeByType(@PathVariable String groupType) {
        return baseGroupService.getBaseGroupTreeByType(groupType);
    }

    /**
     * 保存修改分组
     *
     * @return ResponseInfo
     */
    @RequestMapping("/save")
    public ResponseInfo<String> saveBaseGroup() {
        return baseGroupService.saveBaseGroup(this.getParamMap(request));
    }

    /**
     * 删除分组
     *
     * @param paramMap paramMap
     * @return ResponseInfo
     */
    @RequestMapping("/delete")
    public ResponseInfo<String> deleteBaseGroup(@RequestBody Map<String, Object> paramMap) {
        return baseGroupService.deleteBaseGroup(paramMap);
    }

}
